#include<iostream>
#include<math.h>
using namespace std;
bool sushu(int s)
{
	int i=2;
	while(i<=pow(s,0.5))
	{
		if(s%i==0)
			return false;
		i++;
	}
	return true;
}

int main()
{
	int n=1,k=0,flag=0;
	while(n<=1000)
	{
		if(sushu(n))
			{
				cout<<n<<" ";
				k++;
				flag=1;
			}
		n++;
		if((k%5!=0&&flag)||(k%5==0&&!flag))
			continue;
		cout<<endl;
		flag=0;
	}
	return 0;
}
